/*
 SpellFormatter.m
 iSpeLL
 
 Created by liulei on 5/18/10.
 Copyright 2010 cool8jay@qq.com. All rights reserved.
 */
#import "SpellFormatter.h"


@implementation SpellFormatter

- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
{
	if (filterCharacterSet != nil)
	{
		int i = 0;
		int len = [partialString length];
		
		if(len>99){
			return NO;
		}
		
		for (i = 0; i < len; i++)
		{
			if (![filterCharacterSet characterIsMember:[partialString characterAtIndex:i]])
			{
				return NO;
			}
		}
	}
	return YES;
}

- (void) setAcceptableCharacterSet:(NSCharacterSet *) inCharacterSet
{
	[inCharacterSet retain];
	[filterCharacterSet release];
	filterCharacterSet = inCharacterSet;
}

- (NSString *)stringForObjectValue:(id)anObject
{
	if ([anObject isKindOfClass:[NSString class]])
	{
		return anObject;
	}
	
	return nil;
}

- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error
{
	if (anObject && string)
	{
		*anObject = [NSString stringWithString:string];
	}
	
	return YES;
}

@end
